<!--
 * @Description:
 * @Author: cgt
 * @Date: 2021-11-26 09:37:25
 * @LastEditors: cgt
 * @LastEditTime: 2021-12-28 20:01:55
-->
<template>
  <div>
    <el-button type="primary" @click="show">show</el-button>
  </div>
</template>

<script>
import mixins from '../mixins';
export default {
  name: 'TestTool',
  props: {
    getMap: {
      type: Function,
      required: true
    },
    getTool: {
      type: Function,
      required: true
    },
    mapLoadSuccess: Boolean
  },
  mixins: [mixins],
  methods: {
    show() {
      var pos1 = this.getMap().impl.map.unproject([100, 200]).toArray();
      var pos2 = this.getMap().impl.map.unproject([500, 200]).toArray();
      var pos3 = this.getMap().impl.map.unproject([900, 200]).toArray();
      var point1 = turf.point(pos1);
      point1.properties = {
        type: 'a'
      };
      var point2 = turf.point(pos2);
      point2.properties = {
        type: 'b'
      };

      var center = turf.point(pos3);
      center.properties = {
        type: 'c'
      };
      this.getMap().impl.map.addSource('_test_symbol_source', {
        type: 'geojson',
        data: turf.featureCollection([point1, point2, center])
      });
      this.getMap().impl.map.addLayer({
        id: '_test_symbol_layer',
        type: 'symbol',
        source: '_test_symbol_source',
        layout: {
          'icon-size': [
            'case',
            ['to-boolean', ['==', ['get', 'type'], 'a']], JSON.parse('["interpolate", ["linear"],["zoom"],6.5,0.35, 13, 0.5, 14,0.6, 15,0.7, 15.5,0.8, 16,0.9, 16.4,1.2]'),
            ['to-boolean', ['==', ['get', 'type'], 'b']], JSON.parse('["interpolate", ["linear"],["zoom"],6.5,0.35, 13, 0.5, 14,0.6, 15,0.7, 15.5,0.8, 16,0.9, 16.4,1.2]'),
            ['to-boolean', ['==', ['get', 'type'], 'c']], 3,
            4
          ],
          'icon-image': [
            'case',
            ['to-boolean', ['==', ['get', 'type'], 'a']], '4130010',
            ['to-boolean', ['==', ['get', 'type'], 'b']], '7110080',
            ['to-boolean', ['==', ['get', 'type'], 'c']], '9070010',
            '1'
          ],
          'text-field': '{type}'
        }
      });
    }
  }
};
</script>

<style>

</style>